import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import 'normalize.css'
import '@/assets/iconfont/iconfont.css'
import * as API from "@/http/api"

import Moment from "moment"
import "@/assets/css/public.css"

import _ from "lodash";
import mianbaoxie from "@/components/MBX.vue"
Vue.component("MBX", mianbaoxie)
Vue.config.productionTip = false
// 接口
Vue.prototype.$API = API
//引入vue-quill-editor富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

//引入vue-quill-editor富文本编辑器css样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)
// 导入加载条

import 'nprogress/nprogress.css'

// 权限过滤
Vue.filter('levels', function (key) {
  let level
  switch (key) {

    case '0': level = '一级权限'; break
    case '1': level = '二级权限'; break
    case '2': level = '三级权限'; break

    default: '暂时没有权限'
  }
  return level
})
// 分类等级过滤
Vue.filter('fenlei', function (key) {
  let level
  switch (key) {

    case 0: level = '一级'; break
    case 1: level = '二级'; break
    case 2: level = '三级'; break

    default: '暂时没有权限'
  }
  return level
})
// 时间过滤
Vue.filter("time", function (key) {
  return Moment(key * 1000).format('YYYY/MM/DD hh:mm:ss')
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

//路由守卫
router.beforeEach((to, from, next) => {
  console.log('1111', to)
  const arr = to.matched.some(item => {
    return item.auth
  })
  if (arr) {
  } else {
    next()
  }
})
